/*
 * #%L
 * InterfaceAPI
 * %%
 * Copyright (C) 2011 Ractoc.com
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package com.ractoc.opengamefinder.api.messages;

import com.ractoc.pffj.api.BasePluginMessage;

/**
 * Wraps the message that needs to be send to the network plugin. This message
 * contains the actual message as well as meta data used for routing.
 * 
 * @author ractoc
 * @version 0.1
 */
public final class NetworkMessage extends BasePluginMessage {

    private BasePluginMessage payload;
    private String originPlugin;
    private String destinationPlugin;

    private int sessionId;
    private int playerId;

    private boolean secure;
    private boolean reliable = true;

    /**
     * Default constructor.
     */
    public NetworkMessage() {
    }

    /**
     * Get the playload, the payload is the actual message which needs to be
     * sent over the network.
     * 
     * @return The actual message that needs to be sent.
     */
    public BasePluginMessage getPayload() {
        return payload;
    }

    /**
     * Set the playload, the payload is the actual message which needs to be
     * sent over the network.
     * 
     * @param payloadParam The actual message that needs to be sent.
     */
    public void setPayload(final BasePluginMessage payloadParam) {
        this.payload = payloadParam;
    }

    /**
     * Get the plugin the message is meant for.
     * @return The plugin the message is meant for.
     */
    public String getDestinationPlugin() {
        return destinationPlugin;
    }

    /**
     * Set the plugin the message is meant for.
     * @param destinationPluginParam The plugin the message is meant for.
     */
    public void setDestinationPlugin(final String destinationPluginParam) {
        this.destinationPlugin = destinationPluginParam;
    }

    /**
     * Is this a secure message?
     * @return Is this a secure message?
     */
    public boolean isSecure() {
        return secure;
    }

    /**
     * Is this a secure message?
     * @param secureParam Is this a secure message?
     */
    public void setSecure(final boolean secureParam) {
        this.secure = secureParam;
    }

    /**
     * Is this a reliable message?
     * @return Is this a reliable message?
     */
    public boolean isReliable() {
        return reliable;
    }

    /**
     * Is this a reliable message?
     * @param reliableParam Is this a reliable message?
     */
    public void setReliable(final boolean reliableParam) {
        this.reliable = reliableParam;
    }

    /**
     * Set the session id linked to the current message, only used on the server.
     * @param sessionIdParam The session id linked to the current message.
     */
    public void setSessionId(final int sessionIdParam) {
        this.sessionId = sessionIdParam;
    }

    /**
     * Get the session id linked to the current message, only used on the server.
     * @return The session id linked to the current message.
     */
    public int getSessionId() {
        return sessionId;
    }

    /**
     * Set the plugin the message originated from.
     * @param originPluginParam The plugin the message originated from.
     */
    public void setOriginPlugin(final String originPluginParam) {
        this.originPlugin = originPluginParam;
    }

    /**
     * Get the plugin the message originated from.
     * @return The plugin the message originated from.
     */
    public String getOriginPlugin() {
        return originPlugin;
    }

    /**
     * Set the player id linked to the current message, only used on the server.
     * @param playerIdParam The player id linked to the current message.
     */
    public void setPlayerId(final int playerIdParam) {
        this.playerId = playerIdParam;
    }

    /**
     * Get the player id linked to the current message, only used on the server.
     * @return The player id linked to the current message
     */
    public int getPlayerId() {
        return playerId;
    }

}
